//
//  user.m
//  yuimall_Iphone
//
//  Created by yuike6 yuike6 on 12-4-17.
//  Copyright (c) 2012年 yuike. All rights reserved.
//

#import "TopUser.h"
#import "header.h"

@implementation TopUser

@synthesize user_id;
@synthesize uid;

@synthesize nick;
@synthesize sex;

@synthesize buyer_credit;
@synthesize seller_credit;

@synthesize avatar;

-(void)dealloc
{
    YRelease(user_id)
    YRelease(uid)
    
    YRelease(nick)
    YRelease(sex)
    
    YRelease(buyer_credit)
    YRelease(seller_credit)
    
    [super dealloc];
}

-(void) privateInit
{
    self.user_id = [NSNumber numberWithDouble:[[self.xmlTree valueAtPath:@"user/uid"] doubleValue]];
    
    self.uid = [self.xmlTree valueAtPath:@"user/uid"];
    
    self.nick = [self.xmlTree valueAtPath:@"user/nick"];
    self.sex = [self.xmlTree valueAtPath:@"user/sex"];
    
    UserCredit * tmp_buyer_credit = [[UserCredit alloc] initWithXmlTree:[self.xmlTree parsedTreeAtPath:@"user/buyer_credit"]];
    self.buyer_credit = tmp_buyer_credit;
    YRelease(tmp_buyer_credit);
    
    UserCredit * tmp_seller_credit = [[UserCredit alloc] initWithXmlTree:[self.xmlTree parsedTreeAtPath:@"user/seller_credit"]];    
    self.seller_credit = tmp_seller_credit;
    YRelease(tmp_seller_credit);
    
    self.avatar = [self.xmlTree valueAtPath:@"user/avatar"];
    
}

-(id) initWithXmlTree:(XMLParsedTree *)tree
{
    self = [super initWithXmlTree:tree];
    if (self) {
        [self privateInit];
    }
    
    return self;
}


-(id) initWithXmlString:(NSString *)xmlString
{
    self = [super initWithXmlString:xmlString];
    if (self) {
        [self privateInit];
    }
    return self;
}

-(id) initWithXmlData:(NSData *)xmlData
{
    self = [super initWithXmlData:xmlData];
    if (self) {
        [self privateInit];
    }
    return self;
}
@end
